package cn.zbh.basic.interceptor.config;

import cn.zbh.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.xml.stream.Location;
@Configuration//配置的意思
public class MyConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//使用拦截器
                .addPathPatterns("/**")//拦截路劲
                .excludePathPatterns("/fastdfs/**")//放行路径
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/verifyCode/**")
                 .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/phoneRegister")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                "/v2/**", "/swagger-ui.html/**");
    }
}
